public class Main {
    public static void main(String[] args) {

        SimpleMenuItem pizza = new SimpleMenuItem("披萨", 8.00);
        SimpleMenuItem Hamburger = new SimpleMenuItem("汉堡", 5.00);
        SimpleMenuItem Cola = new SimpleMenuItem("可乐", 1.99);


        MenuCategory drinks = new MenuCategory("主食");
        drinks.add(pizza);
        drinks.add(Hamburger);

        MenuCategory food = new MenuCategory("饮品");
        food.add(Cola);


        MenuCategory fullMenu = new MenuCategory("菜单");
        fullMenu.add(drinks);
        fullMenu.add(food);


        displayMenu(fullMenu, 0);
    }

    private static void displayMenu(MenuItem menuItem, int level) {

        for (int i = 0; i < level; i++) {
            System.out.print("  ");
        }
        System.out.println(menuItem.getName()); // 打印名称


        for (MenuItem child : menuItem.getChildren()) {
            displayMenu(child, level + 1);
        }
    }
}
